package com.lagou.api;

import org.apache.kudu.client.*;

/*
与插入表数据类似
 */
public class UpdateDemo {
    public static void main(String[] args) {
        String masterAddresses="zb26105";
        KuduClient client = new KuduClient.KuduClientBuilder(masterAddresses).defaultSocketReadTimeoutMs(5000).build();

        try {
            KuduTable stuTable = client.openTable("student");
            KuduSession kuduSession = client.newSession();
            kuduSession.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);

            Update update = stuTable.newUpdate();
            update.getRow().addInt("id",1);
            update.getRow().addString("name","eden");

            kuduSession.flush();
            kuduSession.apply(update);
            kuduSession.close();

        } catch (KuduException e) {
            e.printStackTrace();
        }finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }

        }
    }
}
